<?php
/**
 * 用户相关表
 * @author Administrator
 *
 */
class Application_Model_DbTable_User extends Application_Model_DbTable_Base
{
    protected $_name = 'user';
    
	public function isAdmin($login_name = '', $password = '') {
		try{
			$user = $this->fetchRow("login_name = '$login_name' and password='$password'");
			if ($user) {
				$this->_data = $user->toArray();
				//if ($password == $user->password) {
					//if ($user->is_admin == 1) {
						return $user->toArray();
					//}			
				//}
			}
		}catch (Exception $e){
			return $e->getMessage();			
		}
	}
	
	/**
	 * 根据用户名查找用户信息
	 * @param string $username
	 */
	public function getUserByUsername($username){
		$select = $this->select();
		$select->where("username=?",$username);
		return $this->fetchRow($select);
	}
	
	/**
	 * 取得用户列表
	 */
	public function getUserListForFlex($pageM = NULL){
		$rows = $this->jqfetchAll($pageM);
		return $rows;
	}

	
	public function getKVnameid(){
		//$select = $this->select();
		//$select->columns(array("id","showname"));
		$rows = $this->fetchAll();
		$data = array();
		foreach ($rows as $r){
			$data[$r->id] = $r->showname;
		}
		return $data;
	}
}

